package com.example.handle;

import javax.annotation.Resource;

import com.example.service.IRedisService;
import org.springframework.stereotype.Service;

import com.event.binlog.iface.IDistributedLockService;
@Service
public class DistributedLockService implements IDistributedLockService {

    @Resource
    private IRedisService redisService;

    @Override
    public boolean lock(String key, int timeout) {
        return redisService.getLock(key, timeout);
    }

    @Override
    public boolean renewal(String key, int timeout) {
        redisService.expire(key, timeout);
        return true;
    }

    @Override
    public void unlock(String key) {
        redisService.delKey(key);
    }
}
